package dashboard;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;

import com.googlecode.objectify.annotation.Serialized;

public class Milestone implements Serializable{


	private Date start;
	private Date end;
	private boolean viewed;
	private double goal;
	@Serialized private List<Long> courses;
	@Serialized private List<String> types;
	private String action;
	
	private boolean finished = false;
	
	public Milestone(Date start, List<Long> courses, Date end, int goal, ArrayList<String> types, String action)
	{
		this.setStart(start);
		this.setEnd(end);
		this.setGoal(goal);
		this.setTypes(types);
		this.setCourses(courses);
		this.setAction(action);
		this.viewed=false;
	
	}
	
	public Milestone(){}
	
	// getters and setters
	public long getId()
	{
		return start.getTime();
	}

	public boolean isViewed() {
		return viewed;
	}

	public void setViewed() {
		this.viewed = true;
	}

	public String getAction() {
		return action;
	}

	public void setAction(String action) {
		this.action = action;
	}

	public double getGoal() {
		return goal;
	}

	public List<Long> getCourses() {
		return courses;
	}
	
	public void setCourses(List<Long> courses) {
		this.courses = courses;
	}

	public void setGoal(double goal2) {
		this.goal = goal2;
	}

	public List<String> getTypes() {
		return types;
	}

	public void setTypes(List<String> types) {
		this.types = types;
	}

	public boolean isFinished() {
		return finished;
	}

	public void setFinished(boolean finished) {
		this.finished = finished;
	}

	public Date getEnd() {
		return end;
	}

	public void setEnd(Date end) {
		this.end = end;
	}

	public Date getStart() {
		return start;
	}

	public void setStart(Date start) {
		this.start = start;
	}
	

	public String checkLength()
	{	
	
		String st = new String();
		 if(courses.size()>1)
		 {
		 st = "all courses";
		 }
		 else{
		 st =CourseRegistry.getInstance().getCourseById(courses.get(0)).getCourseName() ;
		 }
		
		 return st;
	}
}
